package ugc

import (
	"encoding/json"
	"sensitives/service/dic"
	"strconv"

	"github.com/gin-gonic/gin"
)

type signup struct {
	common
}

var Signup signup

func (filter *signup) Check(cx *gin.Context) {
	siteid, _ := strconv.Atoi(cx.Param("siteid"))
	content := cx.PostForm("data")
	type response struct {
		Code bool        `json:"code"`
		Data []sensitive `json:"data"`
	}
	filter.SensWords = make([]sensitive, 0)
	output := response{Code: false, Data: filter.SensWords}
	if content == "" {
		sens_user, _ := json.Marshal(output)
		cx.Writer.Write([]byte(sens_user))
	}
	user_dic := dic.CloudMap[siteid].User
	filter.filter(content, "data", &user_dic)
	output = response{Code: true, Data: filter.SensWords}
	sens_user, _ := json.Marshal(output)
	cx.Writer.Write(sens_user)
}
